package RayTracing;

import java.util.ArrayList;

public class Plane implements Shape{
	
	//########################## Global Variables ###################################
	private double[] normal = new double[3];
	private double offset;
	private int mtlIndex;
	
	
	//########################## Constructors ###################################
	
	public Plane(){
		if (RayTracer.SHOW_LOG){ System.out.println("In Plane Empty Constructor");}
	}


	public Plane(String[] args){
		if (RayTracer.SHOW_LOG){ System.out.println("In Plane Constructor");}
		
		normal[0] = Double.parseDouble(args[0]);
		normal[1] = Double.parseDouble(args[1]);
		normal[2] = Double.parseDouble(args[2]);
		
		
		offset = Double.parseDouble(args[3]);
		mtlIndex = Integer.parseInt(args[4]);
		
		 
	}
	
	//########################## Shape Functions ###################################
	
	@Override
	public double[] getColor(Material mtl, Ray r, ArrayList<Lights> lgtList) {

		double[] N = getNormal();
		return RayTracer.GlobalGetColor(mtl, r, lgtList, N);
		
	}
	
	@Override
	public double getT(Ray ray) {
		double[] V = ray.getV();
		double[] P0 = ray.getP0();
		
		double divisor = Vector.computeDotProduct(V, getNormal());
		double numerator = - (Vector.computeDotProduct(P0, getNormal()) - getOffset()); 

	
		return numerator / divisor;
	}
	
	
	//########################## Getters and Setters ###################################
	
	public double[] getNormal() {
		return normal;
	}

	public void setNormal(double[] normal) {
		this.normal = normal;
	}

	public double getOffset() {
		return offset;
	}

	public void setOffset(double offset) {
		this.offset = offset;
	}

	public int getMtlIndex() {
		return mtlIndex;
	}

	public void setMtlIndex(int mtlIndex) {
		this.mtlIndex = mtlIndex;
	}
	






}
